#include "timer.h"


namespace vortex
{
    Timer::Timer()
    {
#if WIN32
        QueryPerformanceFrequency(&frequency); 
#endif
    }

    void Timer::Start()
    {
#if WIN32
        QueryPerformanceCounter(&startCount);
#else
        start = clock();
#endif
    }

    float Timer::Stop()
    {
#if WIN32
        LARGE_INTEGER endCount;
        QueryPerformanceCounter(&endCount);
        float dt = static_cast<float>(endCount.QuadPart - startCount.QuadPart) / frequency.QuadPart;
        return dt;
#else
        clock_t end = clock();
        float dt = (end - start) * 1.0f / CLOCKS_PER_SEC;
        return dt;
#endif
    }

}
